﻿/*
 * Copyright 2008 Pimm Hogeling, Karim Sempel and Demian Sempel
 * 
 * This file is part of 8bitplays.
 * 
 * 8bitplays is free software: you can redistribute it and/or modify it
 * under the terms of the GNU General Public License as published by the
 * Free Software Foundation, either version 3 of the License, or (at your
 * option) any later version.
 * 
 * 8bitplays is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with 8bitplays. If not, see <http://www.gnu.org/licenses/>.
 */
package nl.sandmen.team.audio {
	import flash.events.EventDispatcher;
	import nl.sandmen.team.events.VolumeManagerEvent;
	/**
	 * @author Team Sandmen
	 */
	public class VolumeManager {
		private static var eventDispatcher:EventDispatcher;
		private static var _volume:Number = .2;
		public static function addEventListener(type:String, listener:Function, useCapture:Boolean = false, priority:int = 0, useWeakReference:Boolean = false):void {
			if (!eventDispatcher) {
				eventDispatcher = new EventDispatcher();
			}
			eventDispatcher.addEventListener(type, listener, useCapture, priority, useWeakReference);
		}
		public static function removeEventListener(type:String, listener:Function, useCapture:Boolean=false):void {
			if (!eventDispatcher) {
				return;
			}
			eventDispatcher.removeEventListener(type, listener, useCapture);
		}
		public static function get volume():Number {
			return _volume;
		}
		public static function set volume(value:Number):void {
			_volume = value;
			eventDispatcher.dispatchEvent(new VolumeManagerEvent(VolumeManagerEvent.NEW_VOLUME));
		}
	}
}